package com.rain.sms.listener;

import com.rain.sms.utils.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @auther 德哲
 * @date 2019/4/29 17:04.
 */
@Component
@RabbitListener(queues = "sms")
public class SmsListener {

    /*@Value("${aliyun.sms.template_code}")
    private String template_code;

    @Value("${aliyun.sms.sign_name}")
    private String sign_name;

    @Autowired
    private SmsUtil smsUtil;*/

    @RabbitHandler
    public void sendSms(Map<String,String> map) throws Exception{
        String mobile = map.get("mobile");
        String code = map.get("code");
        System.out.println(mobile+"--"+code);
        //"{"code":"123"}"
        //smsUtil.sendSms(mobile,template_code,sign_name,"{\"code\":\""+code+"\"}");
    }

}
